package folexpr.compiler.visitors.a1_close;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

import folexpr.compiler.visitors.VisitResult;

public class ClosedFormVisitResult extends VisitResult
{
	private Collection<String> notQuantifiedVarOccurrences;
	
	public ClosedFormVisitResult()
	{
		super();
		this.notQuantifiedVarOccurrences = new ArrayList<String>();
	}
	
	//////////////////////////////////////////////////////////////////////
	
	/** 
	 * 1) merge delle variabili libere di questo oggetto (this) 
	 *    con quelle del parametro newResult
	 *    
	 * 2) concatenazione delle sottoespressioni chiuse dei sue oggeti 
	 */
	public void addResult(ClosedFormVisitResult newResult)
	{
		Iterator i = newResult.getNotQuantifiedVarOccurrences().iterator();
		while (i.hasNext())
		{
			String var = (String)i.next();
			if (!  this.getNotQuantifiedVarOccurrences().contains(var)   )
			{
				this.getNotQuantifiedVarOccurrences().add(var);
			}
		}
		
		this.setResultExpr(this.getResultExpr() + newResult.getResultExpr() );
	}

	//////////////////////////////////////////////////////////////////////
	
	public Collection<String> getNotQuantifiedVarOccurrences() {
		return notQuantifiedVarOccurrences;
	}
	public void setNotQuantifiedVarOccurrences(
			Collection<String> notQuantifiedVarOccurrences) {
		this.notQuantifiedVarOccurrences = notQuantifiedVarOccurrences;
	}


}

